<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/WEB-INF/views/include/taglib.jsp"%>
<html>
<head>
	<title>添加菜谱管理</title>
	<meta name="decorator" content="default"/>
	<script type="text/javascript">
		$(document).ready(function() {
			//$("#name").focus();
			$("#inputForm").validate({
				submitHandler: function(form){
					loading('正在提交，请稍等...');
					form.submit();
				},
				errorContainer: "#messageBox",
				errorPlacement: function(error, element) {
					$("#messageBox").text("输入有误，请先更正。");
					if (element.is(":checkbox")||element.is(":radio")||element.parent().is(".input-append")){
						error.appendTo(element.parent().parent());
					} else {
						error.insertAfter(element);
					}
				}
			});
		});
	</script>
</head>
<body>
	<ul class="nav nav-tabs">
		<li><a href="${ctx}/mess/messHall/">菜谱列表</a></li>
		<li class="active"><a href="${ctx}/mess/messHall/form?id=${messHall.id}">菜谱<shiro:hasPermission name="mess:messHall:edit">${not empty messHall.id?'修改':'添加'}</shiro:hasPermission><shiro:lacksPermission name="mess:messHall:edit">查看</shiro:lacksPermission></a></li>
	</ul><br/>
	<form:form id="inputForm"
			   modelAttribute="messHall"
			   action="${ctx}/mess/messHall/save"
			   method="post"
			   class="form-horizontal">
		<form:hidden path="id"/>
		<sys:message content="${message}"/>

		<legend>添加菜谱</legend>
		<div class="control-group">
			<table id="contentTable" class="table table-striped table-bordered table-condensed">
				<thead>
				<tr>
					<th title="日期">日期</th>
					<th >早餐</th>
					<th >课间水果</th>
					<th >午餐</th>
					<th >晚餐</th>
					<th >加餐</th>
				</tr>
				</thead>
				<tbody>
				<c:forEach items="${messHallList}" var="column" varStatus="vs">
					<tr>
						<td nowrap>
							<input type="hidden" name="messHallList[${vs.index}].id" value="${column.id}"/>
							<input type="hidden" name="messHallList[${vs.index}].planDate" value="<fmt:formatDate value='${column.planDate}' pattern='yyyy-MM-dd'/>"/>
							<fmt:formatDate value="${column.planDate}" pattern="yyyy-MM-dd"/>
							<fmt:formatDate value="${column.planDate}" pattern="E"/>
						</td>
						<td><input type="text" name="messHallList[${vs.index}].breakfast" value="${column.breakfast}"/></td>
						<td><input type="text" name="messHallList[${vs.index}].fruit" value="${column.fruit}"/></td>
						<td><input type="text" name="messHallList[${vs.index}].lunch" value="${column.lunch}"/></td>
						<td><input type="text" name="messHallList[${vs.index}].dinner" value="${column.dinner}"/></td>
						<td><input type="text" name="messHallList[${vs.index}].snock" value="${column.snock}"/></td>
					</tr>
				</c:forEach>
				</tbody>
			</table>
		</div>

		<div class="form-actions">
			<shiro:hasPermission name="mess:messHall:edit"><input id="btnSubmit" class="btn btn-primary" type="submit" value="保 存"/>&nbsp;</shiro:hasPermission>
			<input id="btnCancel" class="btn" type="button" value="返 回" onclick="history.go(-1)"/>
		</div>
	</form:form>
</body>
</html>